<script type="text/javascript" src="<?=base_url();?>java_scripts/vote_scripts.js"></script>
<div>
<?php 
	$error_msg=(!isset($error))?"":$error;
?>
   <table border="0" width="100%">
      <tr>
      	<td style="font-size: 20px;font-weight: bold;">Assign Items</td>
      </tr>
      <tr>
      	<td align="center">
	      	<form action="<?=site_url("vote_management/assignItem")?>" method="post">
	      		<?php 
	      			foreach($topics->result_array() as $topic){	
		      			$id=(!isset($error))?$topic['top_id']:$top_id;
		      			$top_name=(!isset($error))?$topic['top_name']:$top_name;
		      			$top_desc=(!isset($error))?$topic['top_desc']:$top_desc;
		      			$max=(!isset($error))?$topic['top_item_max']:$max_item;
	      		?>
	      		<table border="0" cellpadding="0" cellspacing="0" width="80%">
	      			<tr align="center">
	      				<td height="25" align="right">
	      				<input type="hidden" value="<?=$id?>" name="txttopid" id="txttopid">
	      				Topic Name :&nbsp;&nbsp;&nbsp;
	      				</td>
	      				<td align="left"><input type="text" readonly="readonly" value="<?=$top_name?>" name="txttopname" id="txttopname" maxlength="255" style="width: 250px;" /><div id='existing'><?=$error_msg?></div></td>
	      			</tr>
	      			<tr align="center">
	      				<td height="55" align="right">Item Category :&nbsp;&nbsp;&nbsp;</td>
	      				<td align="left">
	      					<select name="selcat" id="selcat" onchange="javascript:changeCategory('<?=site_url("vote_management/assignItemForm/".$id)?>')">
	      						<?php 
	      							foreach ($categories->result_array() as $category) {
	      								$selectMe=($cat_id==$category['vote_item_cat_id'])?"selected":"";
	      						?>
	      						<option <?=$selectMe?> value="<?=$category['vote_item_cat_id']?>"><?=$category['vote_item_cat_desc']?></option>
	      						<?php 
	      							}
	      						?>
	      					</select>
	      				</td>
	      			</tr>
	      			<tr align="center">
	      				<td height="55" align="right" valign="top">Choose Item(s):&nbsp;&nbsp;&nbsp;</td>
	      				<td align="left">
	      					<?php 
								foreach ($items->result_array() as $item){
									$foundme=false;
									foreach($curitems->result_array() as $curitem ){
										if($curitem['vote_item_id']==$item['vote_item_id']){
											$foundme=true;
											break;
										}
									}
									$checkme=($foundme==true)?"checked":"";
							?>
								<input type="checkbox" <?=$checkme?> name="myItem[]" value="<?=$item['vote_item_id']?>"><?=$item['vote_item_desc']?><br/>
							<?php 
								}
							?>
	      				
	      				</td>
	      			</tr>
	      			<tr align="center">
	      				<td>&nbsp;</td>
	      				<td height="20" colspan="2" align="left"><br/><input type="button" onclick="javascript:window.location='<?=site_url("vote_management/voteTopic")?>'" style="cursor: pointer;" value="Back"/>&nbsp;&nbsp;<input type="submit" class="kh_button" style="cursor: pointer;" value="Assign"/></td>
	      			</tr>

	      		</table>
	      		<?php 
	      			}
	      		?>
	      	</form>
      	</td>
      </tr>
   </table>
</div>
